package com.apestech.framework.file.modul;

import com.apestech.framework.json.JSONObject;

public class KeyPageModul {
	
	private String key;
	private PageModul page=null;
	
	public KeyPageModul(String key){
		this.page=new PageModul();
		this.key = key;
	}
	
	public KeyPageModul(String key, int fetchSize){
		this.page=new PageModul(fetchSize);
		this.key = key;
	}
	
	public String getKey() {
		return key;
	}
	
	public JSONObject toJSON(){
		JSONObject map=new JSONObject();
		map.put("key", this.key);
		map.put("page", this.page.toJSON());
		return map;
	}
	
	public void fromJSON(JSONObject map) throws Exception{
		if(map==null) return;
		this.key=(String) map.get("key");
		JSONObject pmap=map.getJSONObject("page");
		this.page.fromJSON(pmap);
	}
	
	public void addPage(int row){
		this.page.addPage(row);
	}
	
	public int getPage(int index){
		return this.page.getPage(index);
	}
	
	public void setPage(int index, int row){
		this.page.setPage(index, row);
	}
	
	public int getCount(){
		return this.page.getCount();
	}
	
	public void setCount(int count){
		this.page.setCount(count);
	}
	
	public int getFileCount(){
		return this.page.getFileCount();
	}
	
	public int addRow(){
		return this.page.addRow();
	}
	
	public int insRow(){
		return this.page.insRow();
	}
	
	public int removeRow(int index){
		return this.page.removeRow(index);
	}
	
	public IndexModul getFileIndex(int index){
		return this.page.getFileIndex(index);
	}

}
